package whiteFox.member;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

import whiteFox.db.DBConnection;


public class MemberDAO {
	
	MemberBean mBean;
	
	public MemberDAO(){
		
		this.mBean = new MemberBean();
		
	}
	
	
	public boolean memberCheck(String id, String pwd){
		
		boolean checked = false;
		
		DBConnection db ;
		db = DBConnection.getInstance();
		
		Connection con = null;
		PreparedStatement pstmt = null ;
			
		try {
			
			con = db.getConnection();
			
			StringBuffer sql = new StringBuffer();
			
			sql.append("SELECT COUNT(SEQ) AS CNT FROM MEMBER ");
			sql.append(" WHERE EMAIL = ? ");
			sql.append(" 	   AND PW = ? ");
			
			pstmt = con.prepareStatement(sql.toString());
			
			pstmt.setString(1, id);
			pstmt.setString(2, pwd);
			
			ResultSet rs = pstmt.executeQuery();
			
		
			while(rs.next()){
				
				if(rs.getInt("CNT") > 0 ) {
					
					checked = true;
					
				}
			}
 
			
			
		}catch (Exception e){
			
			e.printStackTrace();
			
		}finally{
			
			db.close(con, pstmt);
			
		}
		
		return checked;
		
	}



}
